class PostSend {
  
  Blog _blog;
  var _url;
  
  PostSend(Blog blog, String url){
    _blog = blog;
    _url = url;
  }
  
  XMLHttpRequest sendPost(Map postToSendToServer) {
    XMLHttpRequest request = new XMLHttpRequest();
    request.on.readyStateChange.add((Event event) {
      if (request.readyState != 4) return;
        if (request.status == 200) {
        
		_blog.setPostRequester(new PostsReq(_blog,_url));
		_blog.showPosts();
        
      } else {  //on error
        document.query('#posts').innerHTML = 'error )-: while sending';
      }
    });
    
    request.open("POST", _url, true);
    request.send(JSON.stringify(postToSendToServer));

    return request;
  }
  
  
  
}
